import { createRouter, createWebHistory } from 'vue-router'

/**
 * 路由配置
 */
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: () => import('@/views/HomeView.vue'),
      meta: {
        title: '首页'
      }
    }
  ]
})

/**
 * 全局前置守卫 - 设置页面标题
 */
router.beforeEach((to) => {
  const title = to.meta?.title as string
  if (title) {
    document.title = `${title} - Vue3 快速开发的标准架构`
  }
})

export default router
